Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/v10.x #51

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Fix/v10.x #51

wants to merge 3 commits into from

Conversation

NayThuKhant
Copy link

In Laravel 10.x, the flow of dispatch helper function changed a bit and lucid wont be working on it anymore. To solve it, let me create this PR.

  • run method of Lucid\Bus\UnitDispatcher.php &
  • serve method of Lucid\Bus\ServesFeature.php

will now be using dispatchSync() not the dispatch() that lucid used previously.

@chris-rs
Copy link

@NayThuKhant Great job. Problem with the PR is that dispatchSync will always perform the job/feature synchronously. One of the Lucid features is that jobs/features can be dispatched for delayed/async processing.
Laravel does not return the result anymore after a dispatch but it could be an improvement to choose between sync/async. The consequence of async dispatch is that the result cannot be used, but that is the way async works.

@NayThuKhant
Copy link
Author

@NayThuKhant Great job. Problem with the PR is that dispatchSync will always perform the job/feature synchronously. One of the Lucid features is that jobs/features can be dispatched for delayed/async processing. Laravel does not return the result anymore after a dispatch but it could be an improvement to choose between sync/async. The consequence of async dispatch is that the result cannot be used, but that is the way async works.

I think we can still use runInQueue if only we want to run a job synchronously, isn't it?

    public function runInQueue($unit, array $arguments = [], $queue = 'default')
    {
        // instantiate and queue the unit
        $reflection = new ReflectionClass($unit);
        $instance = $reflection->newInstanceArgs($arguments);
        $instance->onQueue((string)$queue);

        return $this->dispatch($instance);
    }

@ntgraph
Copy link

ntgraph commented Mar 6, 2024

Hello again,
Any chance a contributor to revive this project. It is an important library. If no feature are added, at least keep up to date with the iteration of Laravel version.

@websmurf
Copy link

websmurf commented Mar 29, 2024

@NayThuKhant We're running into a similar issue with the (https://github.com/ksimenic/lucid) fork because of the dispatchSync change.
The difficulty with having to use the runInQueue method is that you need to know the queue name to dispatch your job or operation to.

We use separate queues that are configured in the global queue configuration, thus resulting in jobs being sent to the wrong queue. (basically any queue that is named different than default will go wrong)

In the old situation, they would be dispatched to the correct queue (as configured in the laravel queue config)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants